package cn.jingyuan.owl.model.error.utils;

import cn.jingyuan.owl.model.error.BusinessException;
import cn.jingyuan.owl.model.error.ErrorCode;

public abstract class BusinessExceptionUtils {

    public static BusinessException instance(String code, String codeMsg) {
        return instance(code, codeMsg, null, null, null);
    }

    public static BusinessException instance(String code, String codeMsg, Object[] params) {
        return instance(code, codeMsg, params, null, null);
    }

    public static BusinessException instance(String code, String codeMsg, Object[] params, String detailMessage) {
        return instance(code, codeMsg, params, detailMessage, null);
    }

    public static BusinessException instance(String code, String codeMsg, String detailMessage) {
        return instance(code, codeMsg, null, detailMessage, null);
    }

    public static BusinessException instance(String code, String codeMsg, String detailMessage, Throwable cause) {
        return instance(code, codeMsg, null, detailMessage, cause);
    }

    public static BusinessException instance(String code, String codeMsg, Throwable cause) {
        return instance(code, codeMsg, null, null, cause);
    }

    public static BusinessException instance(String code, String codeMsg, Object[] params, String detailMessage, Throwable cause) {
        return new BusinessException(code, codeMsg, params, detailMessage, cause);
    }

    public static BusinessException instance(ErrorCode errorCode) {
        return instance(errorCode, null, null, null);
    }

    public static BusinessException instance(ErrorCode errorCode, Object[] params) {
        return instance(errorCode, params, null, null);
    }

    public static BusinessException instance(ErrorCode errorCode, Object[] params, String detailMessage) {
        return instance(errorCode, params, detailMessage, null);
    }

    public static BusinessException instance(ErrorCode errorCode, String detailMessage) {
        return instance(errorCode, null, detailMessage, null);
    }

    public static BusinessException instance(ErrorCode errorCode, String detailMessage, Throwable cause) {
        return instance(errorCode, null, detailMessage, cause);
    }

    public static BusinessException instance(ErrorCode errorCode, Throwable cause) {
        return instance(errorCode, null, null, cause);
    }

    public static BusinessException instance(ErrorCode errorCode, Object[] params, String detailMessage, Throwable cause) {
        return instance(
            errorCode.getCode(),
            errorCode.getCodeMsg(),
            params,
            detailMessage,
            cause
        );
    }

}
